

$(function(){
	
	
	
var webSocket = new WebSocket("ws://localhost:8080/apply/ws");

window.onbeforeunload = function(){
     webSocket.close();
     alert("socket连接已关闭");
   };
   
   




webSocket.onopen = function(event){
    console.log("连接成功");
    console.log(event);
};

webSocket.onerror = function(event){
    console.log("连接失败");
    console.log(event);
};

webSocket.onclose = function(event){
    console.log("Socket连接断开");
    console.log(event);
};

webSocket.onmessage = function(event){
   /* //接受服务器消息
    console.log(event);*/
    var data = $.parseJSON(event.data);
    if(data.type==0){
    	$("#grade-title").append("<span style='color:#FF8000;font-size: 12px;'>（你有一个新班级）</span>");
    
    }else if(data.type==1){
    	$("#record-title").append("<span style='color:#FF8000;font-size: 12px;'>（新申请）</span>");   
    }else{
    	window.closed;
    }
}
  

            
  
  
  });